1. Field
The present invention relates to computers, and more specifically, to systems, methods and software relating to avoiding buffer data loss during computer diagnostics.
2. Background
Event tracing can be used to better understand the behavior of a computer program or the computer system itself. Event tracing is useful when creating or debugging software, or when analyzing computer hardware, networks or other such systems. Trace data is usually recorded in a limited size buffer in memory and then consumed. Trace consumption refers to any process where the trace data in the buffer is used and the memory space trace data occupies is freed, so that it can be overwritten by new data. For example, a trace consumer may simply write the trace data to a file on a hard disk so that it can be post-processed or it may generate reports based on trace data. The buffer writing function may be triggered by a hardware interrupt or exception. This function needs to execute quickly, because it may prevent high priority interrupts from executing. In the further text of the invention it is assumed that events may be generated using an exception mechanism, although the invention can be applied to systems where events are generated using an interrupt mechanism. To produce long traces, trace records must be written to the file while tracing, thus freeing space in the buffer for newly arriving records. A trace record may be thought of as a record of the behavior of software or other machine executable instructions. Problems may arise in tracing high frequency events (e.g., taken branches) if the file write cannot keep up with buffer write.
One conventional solution to avoid filling up a buffer is to let the trace writer (e.g., the buffer writer) sleep or spin while the trace consumer (e.g., the file writer) frees up some of the buffer space. However, this solution is not applicable to the tracing of events such as branches taken. When the event is a branch taken the buffer writing function is triggered by an exception, and therefore cannot wait long enough for the buffer space to be freed. Hence, if the trace buffer is full, trace records will be lost.